New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sanitize-basename

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sanitize-basename

Sanitize a file name for cross-platform validity.

  • 2.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
0
Weekly downloads
 
Created
Source

Sanitize Basename

Sanitize a file name for cross-platform validity.

Instead of stripping out forbidden characters, like other libraries do, this library tries to replace them with similar-looking characters, trying to mainting maximum fidelity while still outputting valid file names for all platforms.

Install

npm install sanitize-basename

Usage

import sanitize from 'sanitize-basename';

// Let's sanitize some file names

sanitize ( '../foo' ); // => 'foo'
sanitize ( '<>:"/\\|?*.txt' ); // => '‹›꞉ˮ⁄∖ǀʔ⁎.txt'
sanitize ( 'aaaaaaaaaaaaaaaaa.txt', { maxLength: 10 } ); // => aaaaaa.txt
  • unsanitize-basename: Unsanitize a file name, the inverse of this library.

License

MIT © Fabio Spampinato

Keywords

FAQs

Package last updated on 17 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc